<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div class="app">
        <h2 v-text="n"></h2>
        <h2 v-big="n"></h2>
        <button @click="n++">点我</button>
        <input type="text" v-fbind:value="n">
    </div>
    <script>
        const vm = new Vue({
            data: {
                n: 1
            },
            // 自定义指令 指令与元素成功绑定时 指令所在模板重新解析时会执行
            directives: {
                big(element, binding) {
                    element.innerText = binding.value * 1000
                        // console.log(element, binding);
                },
                fbind: {
                    // 绑定时
                    bind(e, b) {
                        e.value = b.value

                    },
                    // 插入时
                    inserted(e, b) {
                        e.focus()
                    },
                    // 更新时
                    update(e, b) {
                        e.value = b.value
                        e.focus()
                    }
                }
            }
        })
        vm.$mount('.app')
    </script>
</body>

</html>